package com.example.weatherpiano;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.example.weatherpiano.DAO.City;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CitsActivity extends AppCompatActivity {

    String[] emoji_list = {"🥰", "😊", "😎", "🤔", "😝"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cits);

//        获取数据
        Intent intent = getIntent();
        String[] cityLists = intent.getStringArrayExtra("cityList");

//        简单的显示一下
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(CitsActivity.this, android.R.layout.simple_expandable_list_item_1, cityLists);
        ListView cits_list = findViewById(R.id.city_list);
        cits_list.setAdapter(adapter);

//        小彩蛋
        cits_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Random random = new Random();
                int randNumber = random.nextInt((emoji_list.length-1) + 1);
                Toast.makeText(CitsActivity.this, emoji_list[randNumber], Toast.LENGTH_SHORT).show();
            }
        });
    }


}